package com.xueyi.system.signin.manager.impl;

import cn.hutool.core.lang.func.Func;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xueyi.system.signin.domain.query.SigninQuery;
import com.xueyi.system.signin.domain.dto.SigninDto;
import com.xueyi.system.signin.domain.po.SigninPo;
import com.xueyi.system.signin.domain.model.SigninConverter;
import com.xueyi.system.signin.mapper.SigninMapper;
import com.xueyi.common.web.entity.manager.impl.BaseManager;
import com.xueyi.system.signin.manager.ISigninManager;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * 签到管理 数据封装层处理
 *
 * @author xueyi
 */
@Component
public class SigninManager extends BaseManager<SigninQuery, SigninDto, SigninPo, SigninMapper, SigninConverter> implements ISigninManager {
    @Override
    public List<SigninDto> getNowDAte(Long userId) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        List<SigninPo> signinDto =  baseMapper.selectList(Wrappers.<SigninPo>query().lambda()
                .eq(SigninPo::getUserId, userId)
                .eq(SigninPo::getSignInDate,dateFormat.format(new Date())));
        return baseConverter.mapperDto(signinDto);

    }
}
